/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package pl.edu.agh.io.gpstracker.model;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 *
 * @author wkedzior
 */
@Entity
@Table(name = "waysequence")
@NamedQueries({
    @NamedQuery(name = "Waysequence.findAll", query = "SELECT w FROM Waysequence w"),
    @NamedQuery(name = "Waysequence.findByOrder", query = "SELECT w FROM Waysequence w WHERE w.order = :order"),
    @NamedQuery(name = "Waysequence.findByDatetime", query = "SELECT w FROM Waysequence w WHERE w.datetime = :datetime"),
    @NamedQuery(name = "Waysequence.findById", query = "SELECT w FROM Waysequence w WHERE w.id = :id")})
public class Waysequence implements Serializable {
    private static final long serialVersionUID = 1L;
    @Column(name = "order")
    private Integer order;
    @Column(name = "datetime")
    @Temporal(TemporalType.TIMESTAMP)
    private Date datetime;
    @Id
    @Basic(optional = false)
    @Column(name = "id")
    private Long id;
    @JoinColumn(name = "way_id", referencedColumnName = "id")
    @ManyToOne(optional = false)
    private Way way;
    @JoinColumn(name = "node_id", referencedColumnName = "id")
    @ManyToOne(optional = false)
    private Node node;

    public Waysequence() {
    }

    public Waysequence(Long id) {
        this.id = id;
    }

    public Integer getOrder() {
        return order;
    }

    public void setOrder(Integer order) {
        this.order = order;
    }

    public Date getDatetime() {
        return datetime;
    }

    public void setDatetime(Date datetime) {
        this.datetime = datetime;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Way getWay() {
        return way;
    }

    public void setWay(Way way) {
        this.way = way;
    }

    public Node getNode() {
        return node;
    }

    public void setNode(Node node) {
        this.node = node;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Waysequence)) {
            return false;
        }
        Waysequence other = (Waysequence) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "pl.edu.agh.io.gpstracker.model.Waysequence[id=" + id + "]";
    }

}
